// 目标：提供封装了用户操作相关功能的异步请求 api方法
// 导入 axios
import axios from "@/utils/requset.js"
// 按需导出api方法
export const getUsers = (params) =>
  axios({
    url: 'users',
    method: 'get',
    params: params

  })

// 改变用户禁用状态
export const changeUserState = (uid, state) =>
  axios({
    url: `users/${uid}/state/${state}`,
    method: 'put',

  })
// 新增用户
export const addUser = (usrobj) =>
  axios({
    url: 'users',
    method: 'post',
    data: usrobj
  })
// 修改用户
export const editUser = (id, email, mobile) => axios({
  url: `users/${id}`, method: 'put', data: { email, mobile }
})

// 删除用户
export const delUser = (id) => axios({
  url: `users/${id}`, method: 'delete'
})

//为用户分配角色
export const setUserRole = (uid, rid) => axios({
  url: `users/${uid}/role`, method: 'put', data: { rid }
})
